package com.ledi.pay.controller;

import io.swagger.annotations.Api;

import javax.annotation.Resource;
import javax.validation.Valid;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alipay.api.response.AlipayFundCouponOperationQueryResponse;
import com.alipay.api.response.AlipayMarketingCashvoucherTemplateCreateResponse;
import com.ledi.pay.pojo.AgreementPay;
import com.ledi.pay.pojo.AlipayFundCouponOrderAgreementPay;
import com.ledi.pay.pojo.AlipayFundCouponOrderDisburse;
import com.ledi.pay.pojo.AlipayFundCouponOrderRefund;
import com.ledi.pay.pojo.CashTemplete;
import com.ledi.pay.pojo.DistributeRed;
import com.ledi.pay.pojo.LoginAuth;
import com.ledi.pay.pojo.NotifyInfo;
import com.ledi.pay.pojo.OperationQuery;
import com.ledi.pay.pojo.PageQuery;
import com.ledi.pay.pojo.RefundReq;
import com.ledi.pay.response.HongBao;
import com.ledi.pay.service.PayService;
import com.ledi.pay.utill.SuccessTip;
import com.ledi.pay.utill.Tip;

/**
 * 文件名称： com.ledi.pay.controller.PayController.java<br/>
 * 初始作者： 钟小平<br/>
 * 创建日期： 2018年8月7日<br/>
 * 功能说明： 营销活动Controller<br/>
 * =================================================<br/>
 * 修改记录：<br/>
 * 修改作者 日期 修改内容<br/>
 * ================================================<br/>
 * Copyright (乐迪教育科技有限公司-幼儿事业部) 2017-2018.All rights reserved.<br/>
 */
@RestController
@RequestMapping("/alipay")
@Api
public class PayController {

	@Resource
	private PayService payService;

	/**
	 * @api {GET} /alipay/authUrl 授权地址
	 * @apiGroup alipay
	 * @apiName authUrl
	 * @apiVersion 1.0.0
	 */
	@RequestMapping(value = "/authUrl", method = RequestMethod.GET)
	public Tip getUrl() {

		return SuccessTip.buildSuccess(payService.getUrl());
	}

	/**
	 * @api {POST} /alipay/createCashTemplate 创建现金抵用劵模板
	 * @apiGroup alipay
	 * @apiName createCashTemplate
	 * @apiParam {Date} publish_start_time 发放开始时间，早于该时间不能发券。发放开始时间不能大于当前时间15天。格式为：yyyy-MM-dd HH:mm:ss
	 * @apiParam {Date} publish_end_time 发放结束时间，晚于该时间不能发券。券的发放结束时间和发放开始时间跨度不能大于90天。发放结束时间必须晚于发放开始时间。格式为：yyyy-MM-dd
	 *           HH:mm:ss
	 * @apiParam {int} floor_amount 最低额度。设置券使用门槛，只有订单金额大于等于最低额度时券才能使用。币种为人民币，单位为元。该数值不能小于0，小数点以后最多保留两位。
	 * @apiParam {float} amount 面额。每张代金券可以抵扣的金额。币种为人民币，单位为元。该数值不能小于0.1，小数点以后最多保留两位。
	 * @apiParam {int} voucher_quantity 拟发行券的数量。单位为张。该数值必须是大于0的整数。
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "amount": 1.0,
	 *                  "floor_amount": 10.0,
	 *                  "publish_end_time": "2018-08-31 10:26:54",
	 *                  "publish_start_time": "2018-08-01 10:26:54",
	 *                  "voucher_description": "教育缴费",
	 *                  "voucher_quantity": 5
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "body":
	 *                    "{\"alipay_marketing_cashvoucher_template_create_response\":{\"code\":\"10000\",\"msg\":\"Success\",\"confirm_uri\":\"https:\\/\\/market.alipay.com\\/voucher\\/templatePayment.htm?templateId=20180813000730018734001JC26X\",\"fund_order_no\":\"2018081310002001870266181183\",\"template_id\":\"20180813000730018734001JC26X\"},\"sign\":\"AYlUlOofs76qvL2N5q06UiWD0RMQHcO1Awyct4GK4SKkr346Rkak9yrZ+dzuZSc985IQI2qmBiI3yYLFL6RaRVhebCLUU0hGdWrETEHX9QX96LoqnUrUcOnak9595hDpxeFEXdiEuiXtNPjy7bi/3gOpHLn2HvbPq1buD30mdtut54haisGhoMJN+p5pTgXTAmbgun1Fm8bQmCQgWJZCB2NrdJquYQFQB+E2er3v1ncgmt8Gp+YBWRBe+UKSzYJfTRWiT9X/h4rVHXivyqqCB23GtgaT8T5nfzrz8zGfG0VI/IzvNUcNLTlsgtiSoiqcKIa4aIVEJHz2n6oiN/uEgw==\"}"
	 *                    ,
	 *                    "code": "10000",
	 *                    "confirmUri":
	 *                    "https://market.alipay.com/voucher/templatePayment.htm?templateId=20180813000730018734001JC26X"
	 *                    ,
	 *                    "errorCode": "10000",
	 *                    "fundOrderNo": "2018081310002001870266181183",
	 *                    "msg": "Success",
	 *                    "params": {
	 *                    "biz_content":
	 *                    "{\"amount\":1.0,\"brand_name\":\"苏州乐迪教育\",\"floor_amount\":10.0,\"fund_account\":\"chengpf@juziwl.com\",\"notify_uri\":\"https://rmb.ledijiaoyu.com/alipay/receiveNotify\",\"out_biz_no\":\"1028844656510226433\",\"publish_end_time\":\"2018-08-31 10:26:54\",\"publish_start_time\":\"2018-08-01 10:26:54\",\"redirect_uri\":\"https://rmb.ledijiaoyu.com/success.html\",\"rule_conf\":\"{\\\"PID\\\":\\\"2088102173147402\\\"}\",\"voucher_description\":\"[\\\"1、本券不可兑换现金，不可找零。\\\",\\\"2、每个用户最多可以领取1张。\\\",\\\"3、如果订单发生退款，优惠券无法退还。\\\"]\",\"voucher_quantity\":5,\"voucher_type\":\"FIX_VOUCHER\",\"voucher_use_scene\":\"ALIPAY_FEE\",\"voucher_valid_period\":\"{\\\"type\\\": \\\"RELATIVE\\\", \\\"duration\\\": 20 , \\\"unit\\\": \\\"DAY\\\"  }\"}"
	 *                    },
	 *                    "subCode": "",
	 *                    "subMsg": "",
	 *                    "success": true,
	 *                    "templateId": "20180813000730018734001JC26X"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/createCashTemplate", method = RequestMethod.POST)
	public Tip createCashTemplate(@RequestBody CashTemplete cashTemplete) {

		AlipayMarketingCashvoucherTemplateCreateResponse creatTemplete = payService.creatTemplete(cashTemplete);
		return SuccessTip.buildSuccess(creatTemplete);
	}

	/**
	 * @api {POST} /alipay/cashTemplateList 现金抵用劵模板列表
	 * @apiGroup alipay
	 * @apiName cashTemplateList
	 * @apiParam {Date} publish_start_time 模板创建开始时间
	 * @apiParam {Date} publish_end_time 模板创建结束时间
	 *           HH:mm:ss
	 * @apiParam {int} page_num 页码
	 * @apiParam {float} page_size 每页记录条数
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "create_start_time":"2017-01-01 00:00:01",
	 *                    "create_end_time":"2017-01-29 23:59:59",
	 *                    "page_num":1,
	 *                    "page_size":20
	 *                    }
	 */
	@RequestMapping(value = "/cashTemplateList", method = RequestMethod.POST)
	public Tip cashTemplateList(@RequestBody PageQuery pageQuery) {

		return SuccessTip.buildSuccess(payService.cashTempleteList(pageQuery));
	}

	/**
	 * @api {POST} /alipay/sendVoucher 获取用户信息并发送抵用券
	 * @apiGroup alipay
	 * @apiName sendVoucher
	 * @apiParam {String} authCode 授权码
	 * @apiParam {String} state 回话状态码
	 * @apiSuccess {String} url 用户领劵地址
	 * @apiSuccess {int} money 领劵金额
	 * @apiSuccess {int} gmtExpired 劵过期时间
	 * @apiSuccess {int} status 券状态(ENABLED:可用,DISABLED:不可用,DELETE:删除状态,TRANS:发放中,TRANSFER:已转增,UNC:未领取,
	 *             USED:已使用,USING:使用中,REFUNDED:已退款,REFUNDING:使用中,UNACTIVE:未激活,EXPIRED:已过期)
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "authCode":"sdsdfsdfsdfsdf1123123123123",
	 *                    "state":"sdsdfsdfsdfsdf1123123123123-0sdf"
	 *                    }
	 */
	@RequestMapping(value = "/sendVoucher", method = RequestMethod.POST)
	public Tip sendVoucher(@RequestBody @Valid LoginAuth auth) {

		HongBao authLogin = payService.authLogin(auth);
		return SuccessTip.buildSuccess(authLogin);
	}

	/**
	 * @api {GET} /alipay/receiveNotify 若在创建券模板时传入了notify_uri字段并且有效，当创建的券产生核销行为时会执行调用
	 * @apiGroup alipay
	 * @apiName receiveNotify
	 * @apiParam {String} notify_type 通知类型
	 * @apiParam {String} notify_id 通知id
	 * @apiParam {String} notify_time 通知时间
	 * @apiParam {String} sign_type 签名类型
	 * @apiParam {String} sign 签名
	 * @apiParam {String} status 使用状态
	 * @apiParam {Object} biz_content 使用对象
	 * @apiParam {String} ...alipay_biz_no 商户编号
	 * @apiParam {String} ...biz_time 商户时间
	 * @apiParam {String} ...flux_amount 金额
	 * @apiParam {String} ...voucher_id 抵用劵id
	 * @apiParam {String} ...partnerId 合作伙伴id
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 */
	@RequestMapping(value = "/receiveNotify", method = RequestMethod.GET)
	public Tip receiveNotify(@RequestParam NotifyInfo notifyInfo) {

		payService.receiveNotify(notifyInfo);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /alipay/templete/{templeteId} 模板详情
	 * @apiGroup alipay
	 * @apiName templeteDetil
	 * @apiVersion 1.0.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "amount": "1.00",
	 *                    "body":
	 *                    "{\"alipay_marketing_voucher_templatedetail_query_response\":{\"code\":\"10000\",\"msg\":\"Success\",\"amount\":\"1.00\",\"floor_amount\":\"10.00\",\"publish_amount\":\"0.00\",\"publish_count\":0,\"publish_end_time\":\"2018-08-31 10:26:54\",\"publish_start_time\":\"2018-08-01 10:26:54\",\"recycle_amount\":\"0.00\",\"status\":\"I\",\"template_id\":\"20180813000730018734001JC26X\",\"total_amount\":\"5.00\",\"used_amount\":\"0.00\",\"used_count\":0,\"voucher_description\":\"*不可叠加使用，每笔交易最多使用一张券； *本券仅支持在支付宝缴费业务中使用; *不可折现、转让、赠与、继承、代付； *使用该券，发生的退款，券不退还\",\"voucher_name\":\"1.00元代金券\",\"voucher_quantity\":5,\"voucher_type\":\"FIX_VOUCHER\",\"voucher_valid_period\":\"{\\\"duration\\\":28800,\\\"type\\\":\\\"RELATIVE\\\",\\\"unit\\\":\\\"MINUTE\\\"}\"},\"sign\":\"JxU5qDAye8RTZUEcnOqoqhdnBZ98AGYl1RaacGVyUBIeeKe7gm7lSdChrtsXJ76km7mIVwj9cK8BSoTT6pQhiaSQh518yHLWQoYmLEtxLlu8fRLQx9Q10oAnOYjPjhc+dfhK06OJJBN4R86DYjODpr5HHqXng9GtTDuCplrqGY1ly8B+joKTxfTMrUbRDML5Heg4WvNky7lkkYEXq6YCu0e2CAhT36nZoiXMTfiMxBuJ/hWVexM/x4k58QP6OQZC1K+oSDX+feil0kWkJ2/8X16b3zpjnEkqY9/8VXdILHRHVaBc2YySIqBB/FWKNirgjkJ233q6CwEbPgZAZTa9uA==\"}"
	 *                    ,
	 *                    "code": "10000",
	 *                    "errorCode": "10000",
	 *                    "floorAmount": "10.00",
	 *                    "msg": "Success",
	 *                    "params": {
	 *                    "biz_content": "{\"template_id\":\"20180813000730018734001JC26X\"}"
	 *                    },
	 *                    "publishAmount": "0.00",
	 *                    "publishCount": 0,
	 *                    "publishEndTime": "2018-08-31 10:26:54",
	 *                    "publishStartTime": "2018-08-01 10:26:54",
	 *                    "recycleAmount": "0.00",
	 *                    "status": "I",
	 *                    "subCode": "",
	 *                    "subMsg": "",
	 *                    "success": true,
	 *                    "templateId": "20180813000730018734001JC26X",
	 *                    "totalAmount": "5.00",
	 *                    "usedAmount": "0.00",
	 *                    "usedCount": 0,
	 *                    "voucherDescription":
	 *                    "*不可叠加使用，每笔交易最多使用一张券； *本券仅支持在支付宝缴费业务中使用; *不可折现、转让、赠与、继承、代付； *使用该券，发生的退款，券不退还",
	 *                    "voucherName": "1.00元代金券",
	 *                    "voucherQuantity": 5,
	 *                    "voucherType": "FIX_VOUCHER",
	 *                    "voucherValidPeriod": "{\"duration\":28800,\"type\":\"RELATIVE\",\"unit\":\"MINUTE\"}"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/templete/{templeteId}", method = RequestMethod.GET)
	public Tip getTempleteId(@PathVariable("templeteId") String templeteId) {

		return SuccessTip.buildSuccess(payService.getTemplateById(templeteId));
	}

	/**
	 * @api {GET} /alipay/voucher/{voucherId} 抵用劵详情
	 * @apiGroup alipay
	 * @apiName voucherDetil
	 * @apiVersion 1.0.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "availableAmount": "",
	 *                    "billDetails": [
	 *                    {
	 *                    "amount": "",
	 *                    "bizType": "V_USE",
	 *                    "gmtCreate": "2018-08-10 20:56:54",
	 *                    "partnerId": "PARTNER_TAOBAO_ORDER",
	 *                    "partnerName": "",
	 *                    "status": "S",
	 *                    "tradeNo": "2018081021001001670538016107"
	 *                    }
	 *                    ],
	 *                    "body":
	 *                    "{\"alipay_marketing_voucher_query_response\":{\"code\":\"10000\",\"msg\":\"Success\",\"available_amount\":\"0.00\",\"bill_details\":[{\"amount\":\"1.00\",\"biz_type\":\"V_USE\",\"gmt_create\":\"2018-08-10 20:56:54\",\"partner_id\":\"PARTNER_TAOBAO_ORDER\",\"status\":\"S\",\"trade_no\":\"2018081021001001670538016107\"}],\"extend_info\":\"{}\",\"gmt_active\":\"2018-08-10 00:00:00\",\"gmt_create\":\"2018-08-07 13:34:53\",\"gmt_expired\":\"2018-08-13 23:59:59\",\"name\":\"1.00元代金券\",\"status\":\"USED\",\"template_id\":\"20180807000730016704001PGVVK\",\"total_amount\":\"1.00\",\"user_id\":\"2088512871404671\",\"voucher_id\":\"2018080700073002670401WRHEEJ\"},\"sign\":\"fFhTnh6uUFQcquRc/oXh1LVMzVT1GkxC8G/bp43aml3HLTNELDXQWFGwCdv0c1uk39UhuFF3Uw5K5bUPEM9dHil+jnCeshH7oLFe0TAUiyqgE9hmyxXHyQTf/6crCcnYSc1lAuogvpTtDy0QoH/3Yumvv314PU3fcI56BVqUpdxnTgeMR7BKMQUn6nc7VgmGn9nwmCh7sI1m7dN0lk6COGHMdJNOiAQdIzcqF33ZkvV0ZvwEU/8XVcvcSbvFcgdpPgMJmpLh9MoMf/sBSyYu1OR+1NeYIzO5dXDPX2f41qVftkJDRWoaHqpwj4exCPFtXq2X1X61miwYWuEfdxMCqw==\"}"
	 *                    ,
	 *                    "code": "10000",
	 *                    "errorCode": "10000",
	 *                    "extendInfo": "{}",
	 *                    "gmtActive": "2018-08-10 00:00:00",
	 *                    "gmtCreate": "2018-08-07 13:34:53",
	 *                    "gmtExpired": "2018-08-13 23:59:59",
	 *                    "msg": "Success",
	 *                    "name": "1.00元代金券",
	 *                    "params": {
	 *                    "biz_content": "{\"voucher_id\":\"2018080700073002670401WRHEEJ\"}"
	 *                    },
	 *                    "status": "USED",
	 *                    "subCode": "",
	 *                    "subMsg": "",
	 *                    "success": true,
	 *                    "templateId": "20180807000730016704001PGVVK",
	 *                    "totalAmount": "",
	 *                    "userId": "2088512871404671",
	 *                    "voucherId": "2018080700073002670401WRHEEJ"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/voucher/{voucherId}", method = RequestMethod.GET)
	public Tip voucherDetil(@PathVariable("voucherId") String voucherId) {

		return SuccessTip.buildSuccess(payService.getVoucherById(voucherId));
	}

	/**
	 * @api {GET} /alipay/useRule/{pid} 商户使用场景规则PID查询
	 * @apiGroup alipay
	 * @apiName useRule
	 * @apiVersion 1.0.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "alipay_marketing_userule_pid_query_response": {
	 *                    "code": "10000",
	 *                    "msg": "Success",
	 *                    "pids": "2088202967380463,2088202967380464,2088202967380465"
	 *                    },
	 *                    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
	 *                    }
	 */
	@RequestMapping(value = "/useRule/{pid}", method = RequestMethod.GET)
	public Tip useRule(@PathVariable("pid") String pid) {

		return SuccessTip.buildSuccess(payService.getUseRuleByPid(pid));
	}

	/**
	 * @api {POST} /alipay/agreementPay 商户签署无密支付协议，然后通过代扣的方式发红包
	 * @apiGroup alipay
	 * @apiName agreementPay
	 * @apiParam {String} out_order_no 必选 64 商户的授权资金订单号 同一商户不同的订单，商户授权资金订单号不能重复 8077735255938023
	 * @apiParam {String} out_request_no String 必选 64 商户本次资金操作的请求流水号 同一商户每次不同的资金操作请求，商户请求流水号不要重复 8077735255634078
	 * @apiParam {String} order_title String 必选 100 业务订单的简单描述，如商品名称等 长度不超过100个字母或50个汉字 发送红包
	 * @apiParam {String} amount 必选 11 需要支付的金额，单位为：元（人民币），精确到小数点后两位 取值范围：[0.01,100000000.00] 100.00
	 * @apiParam {String} payer_user_id String 必选 32 付款方的支付宝唯一用户号,以2088开头的16位纯数字组成 2088102138117431
	 * @apiParam {String} pay_timeout String 可选 5 该笔订单允许的最晚付款时间，逾期将关闭该笔订单 取值范围：1m～7d。m-分钟，h-小时，d-天。 该参数数值不接受小数点， 如
	 *           1.5h，可转换为90m，如果为空，默认1h 1h
	 * @apiParam {String} extra_param String 可选 300 业务扩展参数，用于商户的特定业务信息的传递，json格式
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "amount": 1.00
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "amount": "1.00",
	 *                    "authNo": "2018081410002001870279082265",
	 *                    "gmtTrans": "2018-08-14 17:10:12",
	 *                    "id": 1,
	 *                    "operationId": "20180814351245008702",
	 *                    "outOrderNo": "1029294100036763650",
	 *                    "outRequestNo": "1029294100036763651",
	 *                    "status": "SUCCESS"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/agreementPay", method = RequestMethod.POST)
	public Tip agreementPay(@RequestBody AgreementPay agreementPay) {

		AlipayFundCouponOrderAgreementPay creatTemplete = payService.agreementPay(agreementPay);
		return SuccessTip.buildSuccess(creatTemplete);
	}

	/**
	 * @api {POST} /alipay/orderDisburse 将某一个红包进行拆解并打款给用户，即用户领取红包
	 * @apiGroup alipay
	 * @apiName orderDisburse
	 * @apiParam {String} out_order_no 必选 64 商户的授权资金订单号 同一商户不同的订单，商户授权资金订单号不能重复 8077735255938023
	 * @apiParam {String} out_request_no 必选 64 商户本次资金操作的请求流水号 同一商户每次不同的资金操作请求，商户请求流水号不要重复 8077735255634078
	 * @apiParam {String} order_title 必选 100 业务订单的简单描述，如商品名称等 长度不超过100个字母或50个汉字 发送红包
	 * @apiParam {String} amount 必选 11 需要支付的金额，单位为：元（人民币），精确到小数点后两位 取值范围：[0.01,100000000.00] 100.00
	 * @apiParam {String} deduct_auth_no 特殊可选 64
	 *           发放红包时产生的支付宝资金订单号。deduct_auth_no与下面的deduct_out_order_no不能同时为空，二者都存在时，以deduct_auth_no为准
	 *           。为了保证支付的高效，建议商户传入deduct_auth_no
	 * @apiParam {String} pay_timeout 可选 5 该笔订单允许的最晚付款时间，逾期将关闭该笔订单 取值范围：1m～7d。m-分钟，h-小时，d-天。 该参数数值不接受小数点， 如
	 *           1.5h，可转换为90m，如果为空，默认1h 1h
	 * @apiParam {String} extra_param 可选 300 业务扩展参数，用于商户的特定业务信息的传递，json格式
	 * @apiParam {String} payee_user_id 特殊可选 32 收款方的支付宝唯一用户号,以2088开头的16位纯数字组成 2088102138117431
	 * @apiParam {String} payee_logon_id 特殊可选 100 收款方的支付宝登录号，形式为手机号或邮箱等 alitest@alipay.com
	 * @apiSuccess {int} code 返回编码（200成功）
	 * @apiSuccess {String} message 返回说明
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "amount": 0.10,
	 *                  "deduct_auth_no": "2018081410002001870279082265",
	 *                  "payee_logon_id": "17664566644",
	 *                  "payee_user_id": "2088802407721573"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "amount": "0.10",
	 *                    "authNo": "2018081410002001870279180455",
	 *                    "gmtTrans": "2018-08-14 17:32:04",
	 *                    "id": 1,
	 *                    "operationId": "20180814354949178702",
	 *                    "outOrderNo": "1029299603596951554",
	 *                    "outRequestNo": "1029299603596951555",
	 *                    "status": "SUCCESS"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/orderDisburse", method = RequestMethod.POST)
	public Tip orderDisburse(@RequestBody DistributeRed distributeRed) {

		AlipayFundCouponOrderDisburse creatTemplete = payService.disburse(distributeRed);
		return SuccessTip.buildSuccess(creatTemplete);
	}

	/**
	 * @api {GET} /alipay/refund 退款
	 * @apiGroup alipay
	 * @apiName refund
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "auth_no":"2014070800002001550000014417",
	 *                  "out_request_no":"8077735255634078",
	 *                  "amount":10.00,
	 *                  "remark":"红包退款"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "alipay_fund_coupon_order_refund_response": {
	 *                    "code": "10000",
	 *                    "msg": "Success",
	 *                    "auth_no": "2014070800002001550000014417",
	 *                    "out_order_no": "8077735255938023",
	 *                    "operation_id": "2014070800032850551",
	 *                    "out_request_no": "20140707001555633",
	 *                    "amount": 10,
	 *                    "status": "SUCCESS",
	 *                    "gmt_trans": "2014-09-15 11:23:04"
	 *                    },
	 *                    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
	 *                    }
	 */
	@RequestMapping(value = "/refund", method = RequestMethod.POST)
	public Tip refund(@RequestBody RefundReq refundReq) {

		AlipayFundCouponOrderRefund creatTemplete = payService.refund(refundReq);
		return SuccessTip.buildSuccess(creatTemplete);
	}

	/**
	 * @api {GET} /alipay/operationQuery 查看红包
	 * @apiGroup alipay
	 * @apiName operationQuery
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "auth_no":"2014021601002000640012345678",
	 *                  "out_order_no":"8077735255938023",
	 *                  "operation_id":"20140216010020006400",
	 *                  "out_request_no":"2014021600100146"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "amount": "1.00",
	 *                    "authNo": "2018081410002001870279082265",
	 *                    "body":
	 *                    "{\"alipay_fund_coupon_operation_query_response\":{\"code\":\"10000\",\"msg\":\"Success\",\"amount\":\"1.00\",\"auth_no\":\"2018081410002001870279082265\",\"extra_param\":\"{\\\"merchantExt\\\":\\\"orderExpiredTime=480h\\\"}\",\"gmt_create\":\"2018-08-14 17:10:12\",\"gmt_trans\":\"2018-08-14 17:10:12\",\"operation_id\":\"20180814351245008702\",\"operation_type\":\"PAY\",\"order_title\":\"乐校收缴费红包\",\"out_order_no\":\"1029294100036763650\",\"out_request_no\":\"1029294100036763651\",\"payer_logon_id\":\"chengpf@juziwl.com\",\"payer_user_id\":\"2088821837534878\",\"remark\":\"乐校收缴费红包\",\"status\":\"SUCCESS\",\"total_pay_refund_amount\":\"0.00\"},\"sign\":\"SLdnL05QyilYJdwAKKAQN9v7fSkaWygw8wbEoEhibMFTy5UTRU9y7LwXih9tMoLQ3Xg2ps0u/xVrD4Rur1RjTPi+ZCsLlJTNrOyhJDvF/ArWfdcjFX4OmOs7RG1vtotxoDuFy9rODB48RfYOLNFheXNmaUUifqk12sGXv1bvTw3O2FIf4NC+af986UwQm6ICZLw1yLjKKVQ6IGHEWxhK0j2a2brRHnqIMadpv8x6KsyPI/K/umlLG/V8b1trLbKaS763VV7wLgh8Fti+Q9biGukI++NLOwPU07GnrpfoLBN+/iXd13vmO47FYSryuthtC9ZadfUxxKnA3BCHyBeEqw==\"}"
	 *                    ,
	 *                    "code": "10000",
	 *                    "errorCode": "10000",
	 *                    "extraParam": "{\"merchantExt\":\"orderExpiredTime=480h\"}",
	 *                    "gmtCreate": "2018-08-14 17:10:12",
	 *                    "gmtTrans": "2018-08-14 17:10:12",
	 *                    "msg": "Success",
	 *                    "operationId": "20180814351245008702",
	 *                    "operationType": "PAY",
	 *                    "orderTitle": "乐校收缴费红包",
	 *                    "outOrderNo": "1029294100036763650",
	 *                    "outRequestNo": "1029294100036763651",
	 *                    "params": {
	 *                    "biz_content":
	 *                    "{\"auth_no\":\"2018081410002001870279082265\",\"operation_id\":\"20180814351245008702\"}"
	 *                    },
	 *                    "payeeLogonId": "",
	 *                    "payeeUserId": "",
	 *                    "payerLogonId": "chengpf@juziwl.com",
	 *                    "payerUserId": "2088821837534878",
	 *                    "remark": "乐校收缴费红包",
	 *                    "status": "SUCCESS",
	 *                    "subCode": "",
	 *                    "subMsg": "",
	 *                    "success": true,
	 *                    "totalPayRefundAmount": "0.00"
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@RequestMapping(value = "/operationQuery", method = RequestMethod.POST)
	public Tip operationQuery(@RequestBody OperationQuery operationQuery) {

		AlipayFundCouponOperationQueryResponse creatTemplete = payService.operationQuery(operationQuery);
		return SuccessTip.buildSuccess(creatTemplete);
	}

}
